<template>
	<view class="px-3 py-2">
		<view class="d-flex j-sb">
			<text>评论 {{items.length}}</text>
			<view class="comment-btn" @click="goComment">
				<image src="/static/pl.png" style="width: 40rpx;height: 40rpx;" mode=""></image>
			</view>
		</view>
		<view class="comment-item my-2" v-for="item in items">
			<view class="user-msg d-flex a-center">
				<image style="width: 60rpx;height: 60rpx;border-radius: 50%;"
				 :src="item.useravatar" mode=""></image>
				<text class="text-dark ml-1 font">{{item.username}}</text>
			</view>
			<view class="comment-content font-sm text-light-dark line-h-md">
				{{ item.content }}
			</view>
		</view>
	</view>
</template>

<script>
	import { getCommentByThing_id } from "@/api/comment.js"
	export default {
		props: {
			type: {
				type: String
			},
			contentId: {
				type:String
			},
		},
		data(){
			return {
				items:[
					{
						username:'d',
						content:'d'
					}
				]
			}
		},
		watch:{
			contentId: {
				handler: function(v) {
					getCommentByThing_id({
						thing_id: v
					}).then(res=>{
						this.items = res.data
					})
	
				},
				immediate: true
			}
		},
		methods: {
			goComment() {
				uni.navigateTo({
					url: `/pages/pj/pj?type=${this.type}&id=${this.contentId}`,
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			}
		}
	}
</script>

<style>
</style>